#ifndef MYSERIALPORT_H
#define MYSERIALPORT_H

#include <QByteArray>
#include <QString>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QObject>
#include <QDebug>

class MySerialPort:public QObject
{
    Q_OBJECT
public:
    MySerialPort();
    ~MySerialPort();

public slots:
    void myopen(QString com,
                QSerialPort::BaudRate baudRate,
                QSerialPort::StopBits stopBits,
                QSerialPort::DataBits dataBits,
                QSerialPort::Parity dataParity);
    void close();
    void send(QByteArray data);


signals:
    // 发送数据给界面
    void sendMsg(QByteArray msg);

    void openStatus(bool isOpen);

private slots:
    // 接收串口数据
    void onReceived();



private:
    QSerialPort *serialPort;
    QByteArray buffer;
};

#endif // MYSERIALPORT_H
